<?php
namespace Common\Controller;
use Common\Controller\BehaviorController;
use Common\Model\InfoContentModel;
use Common\Model\UserModel;

class UserController extends BehaviorController {

    public function __construct(){
        parent::__construct();
        $this->IsLogin();
    }

    public function getUserInfo(){
        $userKey = C('COOK_LOGIN_KEY') . '_uid';
        $cookie = cookie($userKey);
        if($cookie){
            $uid = explode('_',$cookie)[0];
            if($uid){
                $userModel = new UserModel();
                $userData = $userModel->getUserById($uid);
                return $userData;
            }
        }
        return array();
    }

    public function getInfoById($id){
        $infoModel = new InfoContentModel();
        $infoData = $infoModel->getInfoById($id);
        return $infoData;
    }
}